<!--
@author pan
@createDate 2022/02 2022/2/28 15:16
-->
<script setup lang="ts" name="JsonFormSelect">
import {
  JsonFormItemType,
  JsonFormOptions,
} from 'components/json-form/JsonForm.type'
import {
  extractElFormItemCompProp,
  extractElFormItemCompEvent,
} from './JsonFormUtil'

const props = withDefaults(
  defineProps<{
    item: JsonFormItemType
    formData: any
    options?: JsonFormOptions[]
  }>(),
  { options: () => [] }
)
</script>

<template>
  <el-select
    v-model="formData[item.fieldProp]"
    v-bind="extractElFormItemCompProp(props.item)"
    v-on="extractElFormItemCompEvent(props.item)"
  >
    <el-option
      v-for="item in options"
      :key="item.code"
      :label="item.label"
      :value="item.code"
    >
    </el-option>
  </el-select>
</template>

<style lang="scss" scoped></style>
